import java.util.ArrayList;

import javax.swing.ImageIcon;


public class King extends Piece
{
	public King()
	{
		super();
	}
	public King(int x, int y, boolean isWhite)
	{
		super(x, y, isWhite);
		updateImage();
	}
	
	public void updateImage()
	{
		if(isBackgroundWhite())
		{
			if(isWhite() == true)
			{
				setImage(new ImageIcon("images/whiteKingWhite.gif", ""));
			}
			else
			{
				setImage(new ImageIcon("images/blackKingWhite.gif", ""));
			}
		}
		else
		{
			if(isWhite() == true)
			{
				setImage(new ImageIcon("images/whiteKingBlack.gif", ""));
			}
			else
			{
				setImage(new ImageIcon("images/blackKingBlack.gif", ""));
			}
		}
		if(isHighlightedRed())
		{
			highlightRed();
		}
	}
	
	public void highlightRed()
	{
		if(isWhite())
		{
//			System.out.println("I am the white Tiger");
			setImage(new ImageIcon("images/whiteKingRed.gif", ""));
			setIsHighlightedRed(true);
		}
		else
		{
//			System.out.println("I am the black Tiger");
			setImage(new ImageIcon("images/blackKingRed.gif", ""));
			setIsHighlightedRed(true);
		}
	}
	public void deHighlight()
	{
		updateImage();
		setIsHighlightedRed(false);
	}
	
	public ArrayList<Location> getPossibleMoves(Spot[][] spot)
	{
		ArrayList<Location> list = new ArrayList<Location>();
		
		list.add(new Location(getX()+1, getY()+1));
		list.add(new Location(getX()+1, getY()-1));
		list.add(new Location(getX()-1, getY()+1));
		list.add(new Location(getX()-1, getY()-1));
		
		list.add(new Location(getX()+1, getY()));
		list.add(new Location(getX(), getY()+1));
		list.add(new Location(getX()-1, getY()));
		list.add(new Location(getX(), getY()-1));

		
		removeOutOfBounds(list);
		removeSameColor(list, spot);
		
		
		return list;
		
	}
}
